from pages.BasePage import BasePage
from locator.login_locator.LoginLocators import LoginLocator


class LoginPage(BasePage):

    # 账号密码登录
    def user_login(self, username, password):
        path = "腾讯文档-登录页面"
        if self.wait_element_presence(locator=LoginLocator.LoginFlag, path=path):
            self.switch_to_iframe(locator=LoginLocator.login_iframe, type='id', path=path)
            self.click_element(locator=LoginLocator.account_password, path=path)
            self.input_text(locator=LoginLocator.account_input, text=username, path=path)
            self.input_text(locator=LoginLocator.password_input, text=password, path=path)
            self.click_element(locator=LoginLocator.login_button, path=path)
            self.switch_to_page()
